import multiprocessing
import random
from pprint import pprint

init_state = {
    'height': 0,
    'leaf_num': 0
}
params = {
    'sunlight': [1, 3],
    'water': ['low', 'mid', 'high'],
    'temperature': [1, 10],
    'soil': [3, 20],
}


# seq为试验考虑的因子id（从1开始），param为参数
def getCapacity(seq, param):
    seq = seq - 1
    assert seq < len(param), '输入的次序应小于参数数量'
    assert seq >= 0, '次序应当不小于1'
    keys = []
    for key in param.keys():
        keys.append(key)

    print(keys)
    capacity = {}
    for value in param[keys[seq]]:
        if keys[seq] not in capacity:
            capacity[keys[seq]] = []
        capacity[keys[seq]].append(value)
    for i in range(len(capacity[keys[seq]])):
        for item in param.items():
            if item[0] == keys[seq]:
                continue
            if item[0] not in capacity:
                capacity[item[0]] = []
            capacity[item[0]].append(item[1][0])
    return capacity


def run():
    capacity = getCapacity(seq=2, param=params)
    pprint(capacity)


if __name__ == "__main__":
    multiprocessing.freeze_support()
    run()
